<!--- note: all client.userid is changed to myUID variable from index.cfm --->
<CFSET sDate1 = DATEFORMAT(Now(),"mm/dd/yyyy")>
<CFSET sReRoute = FALSE>
<CFSET sCurrentSequence = 0>
<!--- get Editable groups for originator --->
<CFQUERY NAME="getECRTFORMSGROUP" DATASOURCE="#client.company_dsn#">
	SELECT FIELDGROUP FROM ECRTFORMSGROUP
	WHERE FORMCODE='#GetForm.FORMCODE#'
		AND FORMDETAILCODE='#GetForm.FORMCODE#'
		AND PROCESSCODE = '#GetForm.PROCESSCODE#'
		AND ACTIVITYID = 'ORIGINATOR'
</CFQUERY>
<!--- check if user attached file --->
<CFSET lAttach=false>
<CFLOOP FROM=1 TO=6 INDEX="x">
	<CFIF IsDefined("form.eformfileattachment" & x)>
		<CFIF Trim(Evaluate("form.eformfileattachment#x#")) NEQ "">
			<CFSET lAttach=true>
			<CFBREAK>
		</CFIF>
	</CFIF>
	<CFIF IsDefined("form.eformlinkdesc" & x) AND IsDefined("form.eformlinkattach" & x)>
		<CFIF Trim(Evaluate("form.eformlinkattach#x#")) NEQ "http://" AND Evaluate("form.eformlinkdesc#x#") NEQ "">
			<CFSET lAttach=true>
			<CFBREAK>
		</CFIF>
	</CFIF>
</CFLOOP>
<!--- check if there's an existing attachment --->
<CFQUERY NAME="qryAttachmentCode" DATASOURCE="#table_dsn#">
		SELECT *
		FROM #GetForm.TABLENAME_FK#
		WHERE (PERSONNELIDNO = '#GetEmployee.PERSONNELIDNO#')
			<CFLOOP INDEX="x" FROM="1" TO="5">
				<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
					<CFSET theVal = evaluate("Form.old" & evaluate("GetForm.PK_FIELD" & x))>
					AND (#ucase(evaluate("GetForm.PK_FIELD" & x))# = '#theVal#')
				</CFIF>
			</CFLOOP>
</CFQUERY>
<CFIF IsDefined("qryAttachmentCode.ATTACHMENTCODE")>
	
	<CFSET sAttachmentCode=qryAttachmentCode.ATTACHMENTCODE>
	<!---ADDED by mico 01212010--->
	<!---START--->
	<CFIF sAttachmentCode EQ "">
		<CFSET sAttachmentCode = CREATEUUID()>
	</CFIF>
	<!---END--->
	<CFIF sAttachmentCode NEQ "">
		<CFQUERY NAME="qryNoOfAttachments" DATASOURCE=#client.company_dsn#>
			SELECT *
			FROM ECINFORMSATTACH
			WHERE ATTACHMENTCODE = '#sAttachmentCode#'
		</CFQUERY>

		<!--- remove file attachments --->
		<CFLOOP QUERY="qryNoOfAttachments">
			<CFIF IsDefined("form.chkDelFileAtt" & qryNoOfAttachments.CurrentRow)>
				<CFSET sAttachFileCode=Evaluate("form.chkDelFileAtt" & qryNoOfAttachments.CurrentRow)>

				<CFQUERY NAME="qryAttachments" DATASOURCE=#client.company_dsn#>
					SELECT *
					FROM ECINFORMSATTACH
					WHERE ATTACHMENTCODE = '#sAttachmentCode#' AND
						  ATTACHFILECODE = '#sAttachFileCode#'
				</CFQUERY>

				<CFIF qryAttachments.RecordCount>
					<CFSET sExpandedPath=ExpandPath("#client.attachment_path#")>

					<CFTRY>
						<CFSET lCanDelete=true>
						<CFQUERY NAME="qryECINFORMSATTACH" DATASOURCE="#client.company_dsn#">
							DELETE FROM ECINFORMSATTACH
							WHERE ATTACHMENTCODE = '#sAttachmentCode#' AND
								 ATTACHFILECODE = '#sAttachFileCode#'
						</CFQUERY>
						<!--- Added by Maan 06282007 === in connection with copying of file attachments..
						Should not delete file if some form(s) is still using it. --->
						<CFQUERY NAME="qryCheckFileCode" DATASOURCE="#client.company_dsn#">
							SELECT * FROM ECINFORMSATTACH
							WHERE ATTACHFILECODE = '#sAttachFileCode#'
						</CFQUERY>
						<CFIF qryCheckFileCode.RECORDCOUNT NEQ 0>
							<CFSET lCanDelete=false>
						</CFIF>
						<!--- the end --->
						<!--- trap errors --->
						<CFCATCH>
							<CFSET lCanDelete=false>
							<CFSET sWarn=sWarn & "Cannot delete record for file attachment #qryAttachments.DESCRIPTION# " & #CFCATCH.message# & #CFCATCH.DETAIL# & "<br>">
						</CFCATCH>
					</CFTRY>

					<CFIF lCanDelete>
						<CFFILE ACTION="DELETE" FILE="#sExpandedPath##sAttachFileCode#.#ListLast(qryAttachments.DESCRIPTION, '.')#">
					</CFIF>
				</CFIF>
			</CFIF>
		</CFLOOP>
		<CFQUERY NAME="qryNoOfLink" DATASOURCE=#client.company_dsn#>
			SELECT *
			FROM ECINFORMLINKATTACH
			WHERE ATTACHMENTCODE = '#sAttachmentCode#'
		</CFQUERY>

		<!--- remove file attachments --->
		<CFLOOP QUERY="qryNoOfLink">
			<CFIF IsDefined("form.chkDelLinkAtt" & qryNoOfLink.CurrentRow)>
				<CFSET sAttachLink=Evaluate("form.chkDelLinkAtt" & qryNoOfLink.CurrentRow)>
				<CFSET sLinkName=listgetat(sAttachLink, "1", "~")>
				<CFSET sLinkVal=listgetat(sAttachLink, "2", "~")>
				<CFQUERY NAME="qryAttachments" DATASOURCE=#client.company_dsn#>
					SELECT *
					FROM ECINFORMLINKATTACH
					WHERE ATTACHMENTCODE = '#sAttachmentCode#' AND
						  LINKNAME = '#sLinkName#' AND
						  LINKVALUE = '#sLinkVal#'
				</CFQUERY>

				<CFIF qryAttachments.RecordCount>

					<CFTRY>
						<CFQUERY NAME="qryECINFORMSATTACH" DATASOURCE="#client.company_dsn#">
							DELETE FROM ECINFORMLINKATTACH
							WHERE ATTACHMENTCODE = '#sAttachmentCode#' AND
							  LINKNAME = '#sLinkName#' AND
							  LINKVALUE = '#sLinkVal#'
					</CFQUERY>

						<!--- trap errors --->
						<CFCATCH>
							<CFSET lCanDelete=false>
							<CFSET sWarn=sWarn & "Error in Deleting Link Attachment" & "<br>">
						</CFCATCH>
					</CFTRY>
				</CFIF>
			</CFIF>
		</CFLOOP>
	</CFIF>
</CFIF>
<!--- save records and route (add or copy) --->
<CFIF (ISDEFINED("Form.Route") AND ((Form.Route IS "Add & Route") OR (Form.Route IS "Save & Route")))>
	<!--- check for existence --->
	<CFQUERY NAME="IsExist" DATASOURCE="#table_dsn#">
  	SELECT COUNT(*) AS RECCOUNT
		FROM #GetForm.TABLENAME_FK#
		WHERE
			(PERSONNELIDNO       = '#GetEmployee.PERSONNELIDNO#')
			<CFLOOP  INDEX="x" FROM="1" TO="5">
				<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
					<CFSET theVal = evaluate("Form.edt" & evaluate("GetForm.PK_FIELD" & x))>
					AND (#ucase(evaluate("GetForm.PK_FIELD" & x))# = '#theVal#')
				</CFIF>
			</CFLOOP>
  	</CFQUERY>

	<!--- there are duplicate records --->
	<CFIF IsExist.RECCOUNT NEQ 0>
		<CFSET sWarn = "Duplicate record found. Operation aborted.<BR>">
	<CFELSE>
		<CFTRY>
			<CFQUERY NAME="InsertEntry" DATASOURCE="#table_dsn#">
				INSERT
				INTO #GetForm.TABLENAME_FK# (
					PERSONNELIDNO,
					<CFOUTPUT QUERY="GetFields">
						#COLUMNNAME#<CFIF CurrentRow NEQ RecordCount>,</CFIF>
					</CFOUTPUT>
					<CFIF lAttach>
						,ATTACHMENTCODE
					</CFIF>
				) VALUES (
					'#GetEmployee.PERSONNELIDNO#',
					<CFOUTPUT QUERY="GetFields">
						<CFSET sValue = evaluate("Form.edt" & COLUMNNAME)>
						<CFIF lcase(COLUMNTYPE) EQ "ftfloat" OR
									lcase(COLUMNTYPE) EQ "ftinteger">
							#val(sValue)#
						<CFELSEIF lcase(COLUMNTYPE) EQ "ftdatetime" AND Trim(sValue) IS "">
							NULL
						<CFELSEIF lcase(COLUMNTYPE) EQ "ftdatetime" AND Trim(sValue) IS NOT "">
							<CFMODULE TEMPLATE="#client.common_path#cfm_DBdateFormat.cfm" dateConvert="#sValue#">
							<CFSET sDate2 = dateResult>
							#preserveSingleQuotes(sDate2)#
						<CFELSE>
							'#sValue#'
						</CFIF>
						<CFIF CurrentRow NEQ RecordCount>,</CFIF>
					</CFOUTPUT>
					<CFIF lAttach>
						<CFIF NOT isDefined("sAttachmentCode")> 
							<CFSET sAttachmentCode = CreateUUID()>	
							,'#sAttachmentCode#'
						<CFELSEIF isDefined("sAttachmentCode") AND sAttachmentCode NEQ "">
							,'#sAttachmentCode#'
						</CFIF>
					</CFIF>
				)
	      </CFQUERY>
			<CFIF (Form.Route IS "Add & Route")>
				<CFSET sMess = "Record successfully added.<BR>">
			<CFELSE>
				<CFSET sMess = "Record successfully copied.<BR>">
			</CFIF>
			<!--- trap errors --->
			<CFCATCH>
				<CFSET sWarn = #CFCATCH.message# & #CFCATCH.DETAIL#>
			</CFCATCH>
		</CFTRY>
	</CFIF>
	<CFIF lAttach AND lCanAttach>
		<CFLOOP FROM=1 TO=6 INDEX="x">
			<CFIF IsDefined("form.eformfileattachment" & x)>
				<CFIF Trim(Evaluate("form.eformfileattachment#x#")) NEQ "">
					<CFSET sExpandedPath=ExpandPath("#client.attachment_path#")>

					<!--- Check if attachment directory is exist or not 	By: Winston ---->
					<CFIF NOT DirectoryExists("#expandpath(client.attachment_path)#")>
						<CFDIRECTORY ACTION="Create" DIRECTORY="#expandpath(client.attachment_path)#">
						<CFSET sMess = "Attachment path created...">
					</CFIF>

					<CFFILE ACTION="UPLOAD"
						FILEFIELD="form.eformfileattachment#x#"
						DESTINATION="#sExpandedPath#"
						NAMECONFLICT="MakeUnique">
						
					<CFIF File.FileWasSaved>
						<CFSET sAttempted=File.AttemptedServerFile>
						<CFSET Filename="#File.ServerFile#">
						<CFSET EXTENSION = ListLast(Filename,'.')>

						<!--- delete any files in extensions that are not allowed --->
						<CFIF LCase(EXTENSION) eq "cfm" OR
							  LCase(EXTENSION) eq "cfml" OR
							  LCase(EXTENSION) eq "dbm" OR
							  LCase(EXTENSION) eq "dbml" OR
							  LCase(EXTENSION) eq "cgi" OR
							  LCase(EXTENSION) eq "pl" OR
							  LCase(EXTENSION) eq "plx" OR
							  LCase(EXTENSION) eq "asp" OR
						 	  LCase(EXTENSION) eq "js" OR
							  LCase(EXTENSION) eq "exe" OR
							  LCase(EXTENSION) eq "com" OR
							  LCase(EXTENSION) eq "vbs" OR
							  LCase(EXTENSION) eq "vb">
							<CFFILE ACTION="DELETE" FILE="#sExpandedPath##Filename#">
							<CFSET sWarn=sWarn & "Attached file (#sAttempted#) is not allowed.<br>">
						<CFELSE>
							<CFTRY>
								<CFSET lCanRename=true>
								<CFSET sFileAttachCode=CreateUUID()>

								<CFQUERY NAME="qryECINFORMSATTACH" DATASOURCE="#client.company_dsn#">
									INSERT INTO ECINFORMSATTACH
										(ATTACHMENTCODE,
										 ATTACHFILECODE,
										 DESCRIPTION)
									VALUES
										('#sAttachmentCode#',
										 '#sFileAttachCode#',
										 '#PreserveSingleQuotes(sAttempted)#')
								 </CFQUERY>

								<!--- trap errors --->
								<CFCATCH>
									<CFSET lCanRename=false>
									<CFSET sWarn=sWarn & "Cannot save record for file attachment #sAttempted# " & #CFCATCH.message# & #CFCATCH.DETAIL# & "<br>">
								</CFCATCH>
							</CFTRY>
							
							<CFIF lCanRename>
								<CFFILE ACTION="Rename"
									SOURCE="#sExpandedPath##Filename#"
	 										DESTINATION="#sExpandedPath##Filename#">
							<CFELSE>
								<CFFILE ACTION="DELETE" FILE="#sExpandedPath##Filename#">
							</CFIF>
						</CFIF> <!--- file is allowed --->
					</CFIF> <!--- file was saved --->
				</CFIF> <!--- filex has attachment --->
			</CFIF> <!--- filex has attachment --->
			<CFIF IsDefined("form.eformlinkdesc" & x) AND IsDefined("form.eformlinkattach" & x)><!---link attachment--->
				<CFIF Trim(Evaluate("form.eformlinkattach#x#")) NEQ "http://" AND Evaluate("form.eformlinkdesc#x#") NEQ "">
					<CFSET sLinkDesc=EVALUATE("form.eformlinkdesc" & x)>
					<CFSET sLinkVal=EVALUATE("form.eformlinkattach" & x)>
					<CFQUERY NAME="qryExistLinkAttach" DATASOURCE="#client.company_dsn#">
						SELECT *
						FROM ECINFORMLINKATTACH
						WHERE ATTACHMENTCODE='#sAttachmentCode#'
							AND LINKNAME='#sLinkDesc#'
							AND LINKVALUE='#sLinkVal#'
					 </CFQUERY>
					 <CFIF NOT qryExistLinkAttach.RECORDCOUNT>
						 <CFTRY>

							<CFQUERY NAME="qryECINFORMSATTACH" DATASOURCE="#client.company_dsn#">
								INSERT INTO ECINFORMLINKATTACH
									(ATTACHMENTCODE,
									 LINKNAME,
									 LINKVALUE,
									 RECCREATEDBY
									,RECDATECREATED
									,USERID
									,DATELASTUPDATE
									,TIMELASTUPDATE
									 )
								VALUES
									('#sAttachmentCode#',
									 '#sLinkDesc#',
									 '#sLinkVal#',
									 '#myUID#',
									 '#sDate1#',
									 '#myUID#',
									 '#sDate1#',
									 '#TimeFormat(Now(), "HH:mm:ss")#')
							 </CFQUERY>

							<!--- trap errors --->
							<CFCATCH>
								<CFSET sWarn=sWarn & "Error saving link attachment<br>">
							</CFCATCH>
						</CFTRY>
					</CFIF>
				</CFIF>
			</CFIF><!---link attachment--->
		</CFLOOP> <!--- loop 3x for file upload --->
	</CFIF> <!--- proceed with attachment --->
<CFELSE>
	<CFTRY>
		<CFQUERY NAME="checkEntry" DATASOURCE="#table_dsn#">
			SELECT APPROVED, ROUTEID FROM #GetForm.TABLENAME_FK#
			WHERE
				(PERSONNELIDNO = '#GetEmployee.PERSONNELIDNO#')
				<CFLOOP  INDEX="x" FROM="1" TO="5">
					<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
						<CFSET theVal = evaluate("Form.old" & evaluate("GetForm.PK_FIELD" & x))>
						AND (#ucase(evaluate("GetForm.PK_FIELD" & x))# = '#theVal#')
					</CFIF>
				</CFLOOP>
		</CFQUERY>
		<CFIF checkEntry.APPROVED NEQ "" AND checkEntry.APPROVED NEQ "R" AND checkEntry.APPROVED NEQ "D" AND (checkEntry.ROUTEID NEQ "" AND checkEntry.APPROVED NEQ 'N')>
			<CFTHROW type = "ROUTE" message = "Operation aborted." detail = "Record has already been routed. This maybe due to reloading the page after routing a record.">
		<CFELSE>
			<CFIF checkEntry.APPROVED EQ "R" OR checkEntry.APPROVED EQ "B">
				<CFSET sReRoute = TRUE>
			</CFIF>
		</CFIF>

		<CFQUERY NAME="UpdateEntry" DATASOURCE="#table_dsn#">
			UPDATE #GetForm.TABLENAME_FK#
			SET
				<CFOUTPUT QUERY="GetFields">
					<CFSET sValue = evaluate("Form.edt" & COLUMNNAME)>
					<CFIF lcase(COLUMNTYPE) EQ "ftfloat" OR
								lcase(COLUMNTYPE) EQ "ftinteger">
						#COLUMNNAME# = #val(sValue)#
					<CFELSEIF lcase(COLUMNTYPE) EQ "ftdatetime" AND Trim(sValue) IS "">
						 #COLUMNNAME# = NULL
					<CFELSEIF lcase(COLUMNTYPE) EQ "ftdatetime" AND Trim(sValue) IS NOT "">
						<CFMODULE TEMPLATE="#client.common_path#cfm_DBdateFormat.cfm" dateConvert="#sValue#">
						<CFSET sDate2 = dateResult>
						#COLUMNNAME# = #preserveSingleQuotes(sDate2)#
					<!--- Added by Maan 09032007, save default values of non-editable fields --->
					<CFELSEIF (ListFindNoCase(getECRTFORMSGROUP.FIELDGROUP,COLUMNNAME,"@,") EQ 0 OR ISEDITABLEEFORM EQ "N") AND ISVISIBLEEFORM EQ "Y" AND evaluate("form.edt" & COLUMNNAME) EQ "">
						<CFMODULE TEMPLATE="#client.common_path#get_default_value.cfm" EntryValue="#DEFAULTVALUE#">
						<CFSET sValue = sDefaultValue>
						#COLUMNNAME# = '#sValue#'
					<CFELSE>
						#COLUMNNAME# = '#sValue#'
					</CFIF>
					<CFIF CurrentRow NEQ RecordCount>,</CFIF>
				</CFOUTPUT>
				<CFIF lAttach>
					<CFIF NOT isDefined("sAttachmentCode")> 
						<CFSET sAttachmentCode = CreateUUID()>	
						,ATTACHMENTCODE = '#sAttachmentCode#'
					<CFELSEIF isDefined("sAttachmentCode") AND sAttachmentCode NEQ "">
						,ATTACHMENTCODE = '#sAttachmentCode#'
					</CFIF>
				</CFIF>
			WHERE
				(PERSONNELIDNO = '#GetEmployee.PERSONNELIDNO#')
				<CFLOOP  INDEX="x" FROM="1" TO="5">
					<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
						<CFSET theVal = evaluate("Form.old" & evaluate("GetForm.PK_FIELD" & x))>
						AND (#ucase(evaluate("GetForm.PK_FIELD" & x))# = '#theVal#')
					</CFIF>
				</CFLOOP>
		</CFQUERY>
		<CFSET sMess = "Record successfully updated.<BR>">

		<!--- Variable for pre-process validation --->
		<CFSET lPreProcessValidated="No">
		<CFSET lPreProcessShowMsg = "No">
		<!--- Added by Soti, for pre-process validation --->
		<!--- Start --->
		<CFINCLUDE TEMPLATE="./_routePreActivityCheck.cfm">
		<!--- End --->
		<CFIF lPreProcessValidated EQ "No">
			<CFTHROW type="PREPROCESSEXCEPTION" message="Operation aborted." detail="Preprocess validation has failed.">
		</CFIF>

		<CFCATCH TYPE="Any">
			<CFSET sWarn = "#CFCATCH.message#<br>#CFCATCH.DETAIL#">
		</CFCATCH>
	</CFTRY>
	<CFIF lAttach>
		<CFLOOP FROM=1 TO=6 INDEX="x">
			<CFIF IsDefined("form.eformfileattachment" & x)>
				<CFIF Trim(Evaluate("form.eformfileattachment#x#")) NEQ "">
					<CFSET sExpandedPath=ExpandPath("#client.attachment_path#")>

					<!--- Check if attachment directory is exist or not 	By: Winston ---->
					<CFIF NOT DirectoryExists("#expandpath(client.attachment_path)#")>
						<CFDIRECTORY ACTION="Create" DIRECTORY="#expandpath(client.attachment_path)#">
						<CFSET sMess = "Attachment path created...">
					</CFIF>

					<CFFILE ACTION="UPLOAD"
						FILEFIELD="form.eformfileattachment#x#"
						DESTINATION="#sExpandedPath#"
						NAMECONFLICT="MakeUnique">
					<CFIF File.FileWasSaved>
						<CFSET sAttempted=File.AttemptedServerFile>
						<CFSET Filename="#File.ServerFile#">
						<CFSET EXTENSION = ListLast(Filename,'.')>

						<!--- delete any files in extensions that are not allowed --->
						<CFIF LCase(EXTENSION) eq "cfm" OR
							  LCase(EXTENSION) eq "cfml" OR
							  LCase(EXTENSION) eq "dbm" OR
							  LCase(EXTENSION) eq "dbml" OR
							  LCase(EXTENSION) eq "cgi" OR
							  LCase(EXTENSION) eq "pl" OR
							  LCase(EXTENSION) eq "plx" OR
							  LCase(EXTENSION) eq "asp" OR
						 	  LCase(EXTENSION) eq "js" OR
							  LCase(EXTENSION) eq "exe" OR
							  LCase(EXTENSION) eq "com" OR
							  LCase(EXTENSION) eq "vbs" OR
							  LCase(EXTENSION) eq "vb">
							<CFFILE ACTION="DELETE" FILE="#sExpandedPath##Filename#">
							<CFSET sWarn=sWarn & "Attached file (#sAttempted#) is not allowed.<br>">
						<CFELSE>
							<CFTRY>
								<CFSET lCanRename=true>
								<CFSET sFileAttachCode=CreateUUID()>

								<CFQUERY NAME="qryECINFORMSATTACH" DATASOURCE="#client.company_dsn#">
									INSERT INTO ECINFORMSATTACH
										(ATTACHMENTCODE,
										 ATTACHFILECODE,
										 DESCRIPTION)
									VALUES
										('#sAttachmentCode#',
										 '#sFileAttachCode#',
										 '#PreserveSingleQuotes(sAttempted)#')
								 </CFQUERY>

								<!--- trap errors --->
								<CFCATCH>
									<CFSET lCanRename=false>
									<CFSET sWarn=sWarn & "Cannot save record for file attachment #sAttempted# " & #CFCATCH.message# & #CFCATCH.DETAIL# & "<br>">
								</CFCATCH>
							</CFTRY>

							<CFIF lCanRename>
								<CFFILE ACTION="Rename"
									SOURCE="#sExpandedPath##Filename#"
	 										DESTINATION="#sExpandedPath##Filename#">
							<CFELSE>
								<CFFILE ACTION="DELETE" FILE="#sExpandedPath##Filename#">
							</CFIF>
						</CFIF> <!--- file is allowed --->
					</CFIF> <!--- file was saved --->
				</CFIF> <!--- filex has attachment --->
			</CFIF> <!--- filex has attachment --->
			<CFIF IsDefined("form.eformlinkdesc" & x) AND IsDefined("form.eformlinkattach" & x)><!---link attachment--->
				<CFIF Trim(Evaluate("form.eformlinkattach#x#")) NEQ "http://" AND Evaluate("form.eformlinkdesc#x#") NEQ "">
					<CFSET sLinkDesc=EVALUATE("form.eformlinkdesc" & x)>
					<CFSET sLinkVal=EVALUATE("form.eformlinkattach" & x)>
					<CFQUERY NAME="qryExistLinkAttach" DATASOURCE="#client.company_dsn#">
						SELECT *
						FROM ECINFORMLINKATTACH
						WHERE ATTACHMENTCODE='#sAttachmentCode#'
							AND LINKNAME='#sLinkDesc#'
							AND LINKVALUE='#sLinkVal#'
					 </CFQUERY>
					 <CFIF NOT qryExistLinkAttach.RECORDCOUNT>
						 <CFTRY>

							<CFQUERY NAME="qryECINFORMSATTACH" DATASOURCE="#client.company_dsn#">
								INSERT INTO ECINFORMLINKATTACH
									(ATTACHMENTCODE,
									 LINKNAME,
									 LINKVALUE,
									 RECCREATEDBY
									,RECDATECREATED
									,USERID
									,DATELASTUPDATE
									,TIMELASTUPDATE
									 )
								VALUES
									('#sAttachmentCode#',
									 '#sLinkDesc#',
									 '#sLinkVal#',
									 '#myUID#',
									 '#sDate1#',
									 '#myUID#',
									 '#sDate1#',
									 '#TimeFormat(Now(), "HH:mm:ss")#')
							 </CFQUERY>

							<!--- trap errors --->
							<CFCATCH>
								<CFSET sWarn=sWarn & "Error saving link attachment<br>">
							</CFCATCH>
						</CFTRY>
					</CFIF>
				</CFIF>
			</CFIF><!---link attachment--->
		</CFLOOP> <!--- loop 3x for file upload --->
	</CFIF> <!--- proceed with attachment --->
</CFIF>

<!--- ******************************************************************* --->
<!--- ******************************************************************* --->
<!--- *********	  THIS IS THE ROUTING PROCESS                  ********** --->
<!--- *********   STARTS HERE....                              ********** --->
<!--- ******************************************************************* --->
<!--- ******************************************************************* --->

<CFSET theProcess="#GetForm.PROCESSCODE#">
<CFIF sWarn EQ "">
	<CFTRY>
	<!--- get the activity code involved (first record)--->
	<CFQUERY NAME="GetInvAct" DATASOURCE="#client.company_dsn#">
		SELECT ACTIVITYID, MAPPING, ROLECODE, UNITCODE
		FROM CINFFACTIVITY
		WHERE <CFIF ISDEFINED("CLIENT.newformflow")>
				(PROCESSCODE = '#CLIENT.newformflow#')
				<CFSET theProcess="#CLIENT.newformflow#">
			<CFELSE>
				(PROCESSCODE = '#GetForm.PROCESSCODE#')
			</CFIF>
		ORDER BY ORDERID
	</CFQUERY>
	<!--- If Form is re-routed or not (from returned to originator)... - winston--->
	<CFIF sReRoute IS FALSE>
		<CFSET sRouteID = #CreateUUID()#>
		<CFSET sCurrentSequence = 1>
		<CFSET sStarted = "STARTED">
		<CFSET sInitialization = "INITIALIZATION">
	<CFELSE>
		<CFSET sMess = "Re-Route.<BR>">
		<CFSET sRouteID = checkEntry.ROUTEID>
		<CFQUERY NAME="checkCurrSequence" DATASOURCE="#client.company_dsn#">
			SELECT MAX(CURRENTSEQUENCE) AS CURRENTSEQUENCE
			FROM CRGROUTEDETAILS
			WHERE (ROUTEID = '#sRouteID#')
		</CFQUERY>
		<CFSET sCurrentSequence = checkCurrSequence.CURRENTSEQUENCE + 1>
		<CFSET sStarted = "RE-ROUTE">
		<CFSET sInitialization = "#GetInvAct.ACTIVITYID#">
	</CFIF>

	<!--- update the record itself --->
	<!-- Added by Mhel --->
	<!--- Start --->
	<CFINCLUDE TEMPLATE="_saveoverride.cfm">
	<!--- End --->

	<!--- Modified by Soti 05/25/2004
		 Checking of newly routed forms field APPROVED value used to be NULL,
		 changed to 'S' for Submitted for compatibility to BOS/e Personnel Movements
		 because it does not accept NULL values.
		 For iBOS/e APPROVED values are:
		 1. Y for approved
		 2. N for disapproved
		 3. B for back to sender/last approver	- Winston
		 4. R for returned
		 5. S for submitted --->

	<CFIF sReRoute IS FALSE>
		<!--- log to master router --->
		<CFQUERY NAME="SaveRouteMaster" DATASOURCE="#client.company_dsn#">
			INSERT
			INTO CRGROUTEMAIN
				(ROUTEID, DESCRIPTION, TABLENAME_FK,
				ORIGINATOR, PRIORITY, ORGENTITY, INCLUDEEFORM, ROUTEPARAMS,
				RECCREATEDBY, RECDATECREATED, USERID, DATELASTUPDATE, TIMELASTUPDATE)
			VALUES
				('#sRouteID#', '#GetForm.DESCRIPTION#', '#GetForm.TABLENAME_FK#',
				'#myUID#', '#Form.cmbPriority#', '#client.orgent#', '#form.rdoIncludeForm#',
				'levelid="#GetLevelID.LEVELID#"|subcompanycode="#client.subcompany_code#"',
				'#myUID#', '#preserveSingleQuotes(sDate1)#',
				'#myUID#', '#preserveSingleQuotes(sDate1)#',
				'#TIMEFORMAT(Now(), "hh:mmtt")#')
		</CFQUERY>
	</CFIF>
	<!---ADDED BY JEP, TO REMOVE FROM WORKLIST--->
	<CFIF sReRoute>
		<CFQUERY NAME="SaveRouteDetail" DATASOURCE="#client.company_dsn#">
			UPDATE CRGROUTERECORDS
			SET ISHIDE='Y'
			WHERE ISHIDE='N'
				AND ROUTEID='#sRouteID#'
		</CFQUERY>
	</CFIF>
	<!---ENDS HERE--->
	<CFQUERY NAME="SaveRouteDetail" DATASOURCE="#client.company_dsn#">
		INSERT
		INTO CRGROUTEDETAILS
			(ROUTEID, ORDERID, CURRENTSEQUENCE, ROUTER, ROUTERREMARKS, STATUS, ACTIVITYID,
		 	RECCREATEDBY, RECDATECREATED, USERID, DATELASTUPDATE, TIMELASTUPDATE)
		VALUES
			('#sRouteID#', 1, '#sCurrentSequence#', '#myUID#', '', '#sStarted#', '#sInitialization#',
			'#myUID#',
			'#preserveSingleQuotes(sDate1)#',
			'#myUID#',
			'#preserveSingleQuotes(sDate1)#',
			'#TIMEFORMAT(Now(), "hh:mmtt")#')
	</CFQUERY>
	<CFQUERY NAME="SaveRouteRec" DATASOURCE="#table_dsn#">
		UPDATE #GetForm.TABLENAME_FK#
		SET
			ROUTEID = '#sRouteID#',
			APPROVED = 'S'
		WHERE
			(PERSONNELIDNO = '#GetEmployee.PERSONNELIDNO#')
			<CFLOOP  INDEX="x" FROM="1" TO="5">
				<CFIF evaluate("GetForm.PK_FIELD" & x) NEQ "">
					<CFSET theVal = evaluate("Form.old" & evaluate("GetForm.PK_FIELD" & x))>
					AND (#ucase(evaluate("GetForm.PK_FIELD" & x))# = '#theVal#')
				</CFIF>
			</CFLOOP>
	</CFQUERY>
	<CFSET sMess = sMess & "Form routing successfully initialized.<BR>">

	<!--- trap errors --->
	<CFCATCH>
		<CFSET sWarn = #CFCATCH.message# & #CFCATCH.DETAIL#>
	</CFCATCH>
	</CFTRY>
</CFIF>

<CFIF sWarn EQ "">
	<CFTRY>


	<!--- initilize mail and msg variables --->
	<CFSET sMailRecipients = "">
	<CFSET sRecordID = CreateUUID()>
	<CFSET sMsgRecipients = "">
	<CFSET sIntendedRecipient="">
	<CFSET sPerSuperior = "">

	<CFSWITCH EXPRESSION="#lcase(GetInvAct.MAPPING)#">

		<!--------------------------------------->
		<!--- the originator is the recipient --->
		<!--------------------------------------->
		<CFCASE VALUE="originator">
			<!--- this cannot be, it is invalid! --->
			<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" MODULE="#session.tabId#" LOCATION="#session.tabLocation#" COMPONENT="Error in form-flow process">
			<BR><BR>
			<H3>Invalid mapping.</H3>
			<CFOUTPUT>
			Originator to Originator mapping is not allowed.
			Please notify your iBOS/e Administrator.
			</CFOUTPUT>
			<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" TOP="False">
			<CFABORT>
		</CFCASE>

		<!-------------------------------------------------->
		<!--- extract the recipient through the unitcode --->
		<!-------------------------------------------------->
		<CFCASE VALUE="userrole">
			<!--- get intended recipients --->
			<CFQUERY NAME="GetRecipients" DATASOURCE="#client.global_dsn#">
				SELECT USERGRPMEMBERSIDX, GUID FROM EGRGROLEINDEX, EGRGUSERMASTER
				WHERE
					EGRGUSERMASTER.USERID = EGRGROLEINDEX.USERGRPMEMBERSIDX AND
					USERGRPID_FK = '#GetInvAct.ROLECODE#';
			</CFQUERY>

			<!--- if sole individual in role, SIYA NA! --->
			<CFIF GetRecipients.RecordCount EQ 1>
				<CFMODULE TEMPLATE="#client.common_path#cfm_getuser.cfm" USERID="#GetRecipients.USERGRPMEMBERSIDX#">
				<CFIF ISFOUND>
					<!--- log to route records --->
					<CFQUERY NAME="SaveRouteRecords" DATASOURCE="#client.company_dsn#">
						INSERT
						INTO CRGROUTERECORDS
							(USERID_FK, ROUTEDATE, ROUTETIME, ORIGINATOR,
							PROCESSCODE, ACTIVITYID, ROUTEID,
							ISNEW, ISHIDE, RECORDID,
							RECCREATEDBY, RECDATECREATED, USERID, DATELASTUPDATE, TIMELASTUPDATE)
						VALUES
							('#GetRecipients.USERGRPMEMBERSIDX#',
							'#preserveSingleQuotes(sDate1)#',
							'#TIMEFORMAT(Now(), "HH:mm:ss")#', '#myUID#',
							'#theProcess#', '#GetInvAct.ACTIVITYID#', '#sRouteID#',
							'Y','N', '#sRecordID#',
							'#myUID#',
							'#preserveSingleQuotes(sDate1)#',
							'#myUID#',
							'#preserveSingleQuotes(sDate1)#',
							'#TIMEFORMAT(Now(), "hh:mmtt")#')
					</CFQUERY>

					<CFSET sMsgRecipients  = sMsgRecipients  & "(" & PERID & ") " & PERNAME & ", ">
					<CFSET sMailRecipients=PERADDRESS>
					<CFSET sIntendedRecipient=GetRecipients.USERGRPMEMBERSIDX>
				</CFIF>	<!--- recipient is valid --->
			<CFELSE>
				<!--- set unitcode to use --->
				<CFSET sUnitCode2Use=Trim(GetInvAct.UNITCODE)>
				<CFIF sUnitCode2Use IS "">
					<CFSET sUnitCode2Use="UNITCODE">
				</CFIF>

				<!--- get the userid that override members in userrole --->
				<CFQUERY NAME="overridemapping" DATASOURCE="#client.company_dsn#">
					SELECT *
					FROM ECMFUSRDEFINEROLE
					WHERE ROUTEID = '#sRouteID#' AND
						  ACTIVITYID = '#GetInvAct.ACTIVITYID#'
				</CFQUERY>
				<CFSET sCode2Use=Trim(overridemapping.USERID)>

				<CFLOOP QUERY="GetRecipients">
					<CFIF sCode2Use IS "">
						<!--- in case overriding of members in userrole is not
							done by the user before routing the form,
							mapping will re-route to any member of the
							userrole with same unitcode as of the originator --->
						<CFQUERY NAME="GetEntity" DATASOURCE="#client.company_dsn#">
							SELECT #sUnitCode2Use#
							FROM CMFPA
							WHERE GUID = '#GetRecipients.GUID#'
						</CFQUERY>
						<CFSET lContinue="Yes">
					<CFELSEIF sCode2Use IS GetRecipients.USERGRPMEMBERSIDX>
						<CFSET lContinue="Yes">
					<CFELSE>
						<CFSET lContinue="No">
					</CFIF>

					<CFIF lContinue>
						<CFMODULE TEMPLATE="#client.common_path#cfm_getuser.cfm" USERID="#GetRecipients.USERGRPMEMBERSIDX#">
						<CFIF ISFOUND>
							<!--- in case overriding of members in userrole is not
								done by the user before routing the form,
								mapping will re-route to any member of the
								userrole with same unitcode as of the originator --->
							<CFIF sCode2Use IS "">
								<CFQUERY NAME="getdivision" DATASOURCE="#client.company_dsn#">
									SELECT #sUnitCode2Use#
									FROM CMFPA
									WHERE PERSONNELIDNO = '#client.chapa#'
								</CFQUERY>
							</CFIF>

							<CFIF (sCode2Use IS NOT "") OR
								  (
								  	GetEntity.RecordCount AND
									getdivision.RecordCount AND
									ucase(Evaluate("GetEntity." & sUnitCode2Use)) EQ
									ucase(Evaluate("getdivision." & sUnitCode2Use))
								  )
							>
								<!--- log to route records --->
								<CFQUERY NAME="SaveRouteRecords" DATASOURCE="#client.company_dsn#">
									INSERT
									INTO CRGROUTERECORDS
										(USERID_FK, ROUTEDATE, ROUTETIME, ORIGINATOR,
										PROCESSCODE, ACTIVITYID, ROUTEID,
										ISNEW, ISHIDE, RECORDID,
										RECCREATEDBY, RECDATECREATED, USERID, DATELASTUPDATE, TIMELASTUPDATE)
									VALUES
										('#GetRecipients.USERGRPMEMBERSIDX#',
										'#preserveSingleQuotes(sDate1)#',
										'#TIMEFORMAT(Now(), "HH:mm:ss")#', '#myUID#',
										'#theProcess#', '#GetInvAct.ACTIVITYID#', '#sRouteID#',
										'Y','N', '#sRecordID#',
										'#myUID#',
										'#preserveSingleQuotes(sDate1)#',
										'#myUID#',
										'#preserveSingleQuotes(sDate1)#',
										'#TIMEFORMAT(Now(), "hh:mmtt")#')
								</CFQUERY>

								<CFSET sIntendedRecipient=GetRecipients.USERGRPMEMBERSIDX>
								<CFSET sMsgRecipients  = sMsgRecipients  & "(" & PERID & ") " & PERNAME & ", ">
								<CFSET sMailRecipients=PERADDRESS>
							</CFIF>	<!--- unitcode of originator is the same with the recipient --->
						</CFIF>	<!--- recipient is validated --->
					</CFIF>
				</CFLOOP>
			</CFIF>
		</CFCASE>

		<!----------------------------------------------->
		<!--- the immediate superior is the recipient --->
		<!----------------------------------------------->
		<CFDEFAULTCASE> <!--- superior --->
			<CFMODULE TEMPLATE="#client.common_path#cfm_getuser.cfm" USERID="#myUID#">
			<CFIF ISFOUND>
				<CFIF Trim(PERSUPERIOR) NEQ "">
					<CFQUERY NAME="GetCode" DATASOURCE="#client.company_dsn#">
						SELECT GUID, PERSONNELIDNO, LASTNAME #sqlCONCAT# ', ' #sqlCONCAT# FIRSTNAME #sqlCONCAT# ' ' #sqlCONCAT# MIDDLENAME AS NAME
						FROM CMFPA
						WHERE PERSONNELIDNO = '#PERSUPERIOR#'
					</CFQUERY>

					<CFIF GetCode.RecordCount>
						<!--- extract profile name --->
						<CFQUERY NAME="GetProfileName" DATASOURCE="#client.global_dsn#">
							SELECT USERID, PROFILENAME
							FROM EGRGUSERMASTER
							WHERE GUID = '#GetCode.GUID#'
						</CFQUERY>

						<CFIF GetProfileName.RecordCount>
							<CFSET sIntendedRecipient=GetProfileName.USERID>
							<!--- log to route records --->
							<CFQUERY NAME="SaveRouteRecords" DATASOURCE="#client.company_dsn#">
								INSERT
								INTO CRGROUTERECORDS
									(USERID_FK, ROUTEDATE, ROUTETIME, ORIGINATOR,
									PROCESSCODE, ACTIVITYID, ROUTEID,
									ISNEW, ISHIDE, RECORDID,
								 	RECCREATEDBY, RECDATECREATED, USERID, DATELASTUPDATE, TIMELASTUPDATE)
								VALUES
									('#GetProfileName.USERID#',
									'#preserveSingleQuotes(sDate1)#',
									'#TIMEFORMAT(Now(), "HH:mm:ss")#', '#myUID#',
									'#theProcess#', '#GetInvAct.ACTIVITYID#', '#sRouteID#',
									'Y','N', '#sRecordID#',
									'#myUID#',
									'#preserveSingleQuotes(sDate1)#',
									'#myUID#',
									'#preserveSingleQuotes(sDate1)#',
									'#TIMEFORMAT(Now(), "hh:mmtt")#')
							</CFQUERY>

							<CFSET sIntendedRecipient=GetProfileName.USERID>
							<CFSET sMailRecipients=Trim(GetProfileName.PROFILENAME)>
							<CFSET sMsgRecipients = sMsgRecipients  & "(" & GetCode.PERSONNELIDNO & ") " & GetCode.NAME>
						<CFELSE>
							<CFMODULE TEMPLATE="#client.common_path#cfm_error.cfm" MODULE="#session.tabid#" TYPE="SUPERIORNOIBOSE">
						</CFIF> <!--- profile not found --->
					<CFELSE>
						<CFMODULE TEMPLATE="#client.common_path#cfm_error.cfm" MODULE="#session.tabid#" TYPE="SUPERIORNOTEXIST">
					</CFIF> <!--- Approving party's superior doesn't exist in CMFPA --->
				<CFELSE>
					<CFSET sPerSuperior = "">
					<CFMODULE TEMPLATE="#client.common_path#cfm_error.cfm" MODULE="#session.tabid#" TYPE="NOSUPERIOR">
				</CFIF> <!--- Approving party doesn't have superior --->
			</CFIF>
		</CFDEFAULTCASE>
	</CFSWITCH>
	<!--- ************************************************************* --->
	<!--- ************************************************************* --->
	<!--- ******    THE ROUTING PATH IS DEFINED AND EXTRACTED   ******* --->
	<!--- ******    THE PROCESS ENDS HERE                       ******* --->
	<!--- ************************************************************* --->
	<!--- ************************************************************* --->

	<CFIF sIntendedRecipient IS "">
		<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" MODULE="#session.tabId#" LOCATION="#session.tabLocation#" COMPONENT="Error in form-flow process">
		<BR><BR>
		<H3>Intended Recipient is missing.</H3>
		Please notify your iBOS/e Administrator.
		<CFMODULE TEMPLATE="#client.common_path#cfm_workspace.cfm" TOP="False">
		<CFABORT>
	</CFIF>

	<!--- get the process of eform for eform follow-up and forwarding --->
	<CFQUERY NAME="qryCINFFPROCESS" DATASOURCE="#client.company_dsn#">
		SELECT ISFOLLOW, FOLLOWHOURS, ISFORWARD, FORWARDHOURS
		FROM CINFFPROCESS
		WHERE (PROCESSCODE = '#theProcess#')
	</CFQUERY>

	<CFIF UCase(qryCINFFPROCESS.ISFOLLOW) IS "Y" AND qryCINFFPROCESS.FOLLOWHOURS GT 0>
		<CFSET lFollowUp=true>
	<CFELSE>
		<CFSET lFollowUp=false>
	</CFIF>
	<CFIF UCase(qryCINFFPROCESS.ISFORWARD) IS "Y" AND qryCINFFPROCESS.FORWARDHOURS GT 0>
		<CFSET lForward=true>
	<CFELSE>
		<CFSET lForward=false>
	</CFIF>
	<!---added by mico 06102010 for form flow tracker--->
	<!---start--->
	<cfquery name="getTrackoption" datasource="#client.company_dsn#">
			select TRACKOPTION
			from CINFFACTIVITY
			where ACTIVITYID = '#GetInvAct.ACTIVITYID#'
	</cfquery>
	<cfschedule action="delete" task="track#srouteid#">
	<cfif not lforward>
		<cfmodule template="#client.root_path#eforms/fftracker/scheduler.cfm" trackoption="#getTrackoption.trackoption#" routeid="#srouteid#">
	</cfif>
	<!---end---> 
	<!--- set variables for followup or forwarding --->
	<CFIF lFollowUp OR lForward>
		<!--- remove http:// in parameters --->
		<CFIF LCase(Left(client.mailtransporturl, 7)) IS "http://">
			<CFSET sMailTransportURL=Mid(client.mailtransporturl, 8, Len(client.mailtransporturl))>
		<CFELSEIF LCase(Left(client.mailtransporturl, 6)) IS "http//"><!---New condition 11/26/2009--->
			<CFSET sMailTransportURL=Mid(client.mailtransporturl, 7, Len(client.mailtransporturl))>			
		<CFELSE>
			<CFSET sMailTransportURL=client.mailtransporturl>
		</CFIF>
		<CFSET sMailTransportURL=URLEncodedFormat(sMailTransportURL)>
	</CFIF>

	<!--- create schedule for follow-up --->
	<!--- Start --->
	<CFIF lFollowUp AND sMailRecipients IS NOT "">
		<CFSET sURL=client.domain & "schedule/followmail.cfm?mailtransporturl=" & sMailTransportURL &
				"&mailserver=" & URLEncodedFormat(client.mailserver) &
				"&mailbox=" & URLEncodedFormat(client.mailbox) &
				"&userid=" & URLEncodedFormat(sIntendedRecipient) &
				"&mailcontent=" & URLEncodedFormat(client.mailcontent) &
				"&sender=" & URLEncodedFormat(client.myname) &
				"&urldomain=" & "#client.domain#" &
				"&url3=" & URLEncodedFormat(client.companycode) &
				"&url4=" & URLEncodedFormat(sRecordID) &
				"&from=" & URLEncodedFormat(LCase(client.profilename)) &
				"&to=" & URLEncodedFormat(LCase(sMailRecipients)) &
				"&dsn=" & client.company_dsn &
				"&ek=" & URLEncodedFormat(client.ek) &
				"&compname=" & URLEncodedFormat(client.companyname) &
				"&formgroup=" & URLEncodedFormat(GetForm.formgroup) &
				"&formdescription=" & URLEncodedFormat(GetForm.description)>
		<CFIF lForward>
			<CFSET sURL=sURL & "&forward=" & qryCINFFPROCESS.FORWARDHOURS>
		<CFELSE>
			<CFSET sURL=sURL & "&followup=" & qryCINFFPROCESS.FOLLOWHOURS>
		</CFIF>

		<CFSET nFollowHours = qryCINFFPROCESS.FOLLOWHOURS * 60>
		<CFSCHEDULE ACTION="Update"
			TASK="follow#sRecordID#"
			OPERATION="HTTPRequest"
			STARTDATE="#Now()#"
			STARTTIME="#TimeFormat(DateAdd('n', qryCINFFPROCESS.FOLLOWHOURS, Now()))#"
			URL="#sURL#"
			INTERVAL="#nFollowHours#">
	</CFIF>
	<!--- End --->

	<!--- create schedule for forwarding --->
	<!--- Start --->
	<CFIF lForward>
		<!--- get recipients alternate approver --->
		<CFMODULE TEMPLATE="#client.common_path#routing/routefunc_getalternate.cfm"
			USERID="#sIntendedRecipient#">

		<CFIF ALTERNATE NEQ "">
			<!--- Create alternate approver schedule --->
			<CF_IBOSELOG MODULE="EFORMS:UPDATE&ROUTE" LEVEL="INFORMATION" FILE="_saverouteMAPISMTP.cfm"
				MESSAGE="Created schedule for alternate approver: USERID=#sIntendedRecipient#, ALTERNATE=#ALTERNATE#.">
			<CFMODULE TEMPLATE="#client.common_path#routing/routefunc_createsched.cfm"
				MAILTRANSPORTURL = "#sMailTransportURL#"
				USERID = "#sIntendedRecipient#"
				RECORDID = "#sRecordID#"
				PROCESSID = "#theProcess#"
				ACTIVITYID = "#GetInvAct.ACTIVITYID#"
				ROUTEID = "#sRouteID#"
				TABLE_DSN = "#table_dsn#"
				TABLENAME = "#GetForm.TABLENAME_FK#"
				FORMGROUP = "#GetForm.formgroup#"
				FORMDESC = "#GetForm.description#"
				FORWARDHOURS = "#qryCINFFPROCESS.FORWARDHOURS#"
				ALTAPPROVER = "#ALTERNATE#"
				ALTAPPROVERCOUNT = "1"
				ORIGAPPROVER = "#sIntendedRecipient#"
				COMPNAME="#client.companyname#"
				>
		</CFIF>
	</CFIF>
	<!--- End --->

	<!--- trap errors --->
	<CFCATCH>
		<CFSET sWarn = #CFCATCH.message# & #CFCATCH.DETAIL#>
	</CFCATCH>
	</CFTRY>
</CFIF>


